package Listener.lab3;

import javax.swing.*;
import java.awt.*;

/**
 * @Description:自定义监听器实现监听
 * @Author:AMark
 * @Date: 10/30/2023
 */
public class ButtonDemo_other {
    public JButton buttonok,buttoncancel;
    public JFrame Buttonframe;
    ButtonDemo_other(String title) {
        Buttonframe = new JFrame(title);
        Buttonframe.setSize(260, 150);
        Buttonframe.setLayout(new FlowLayout());

        buttoncancel = new JButton("取消");
        buttonok = new JButton("确定");
        buttoncancel.setSize(20, 20);
        buttonok.setSize(20, 20);

        buttonok.addActionListener(new MyActionListener(this));
        buttoncancel.addActionListener(new MyActionListener(this));

        Buttonframe.add(buttoncancel);
        Buttonframe.add(buttonok);
        Buttonframe.setVisible(true);
        Buttonframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    }

    public static void main(String[] args) {
        new ButtonDemo_other("外部类测试");
    }
}
